package org.coding.springbootdemocommandline.fileopr.entity;

import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * ^ enjoy coding and be bugfree boy
 *
 * @author guoxh
 * @date 2020/11/7 7:40 下午
 * @desc
 **/
public class EasyExcelHeadConverter {
    private List<SheetHeaderInfo> sheetHeaderInfos;

    public EasyExcelHeadConverter() {
    }

    public EasyExcelHeadConverter(List<SheetHeaderInfo> sheetHeaderInfos) {
        this.sheetHeaderInfos = sheetHeaderInfos;
    }

    private String columnValue;
    private Integer columnAt;
    private Integer rowAt;

    public List<List<String>> convertEasyExcelHead(){
        List<List<String>> head = new ArrayList<>();
        if(CollectionUtils.isEmpty(sheetHeaderInfos)){
            return head;
        }
        for (int i = 0; i < sheetHeaderInfos.size(); i++) {
            SheetHeaderInfo sheetHeaderInfo = sheetHeaderInfos.get(i);
            int startColumn = sheetHeaderInfo.getHeaderStartColumn();
            int endColumn = sheetHeaderInfo.getHeaderEndColumn();
            for(int j = startColumn;j<=endColumn;j++){
                head.add(Arrays.asList(sheetHeaderInfo.getHeaderValue()));
            }
        }

        return head;
    }
}
